extends KinematicBody2D

var vec = Vector2()
onready var Bullet = load("res://obj/Bullet.tscn")
func _ready():
	pass

func _process(delta):
	if Input.is_action_pressed("w"):
		vec.y = -1
	elif Input.is_action_pressed("s"):
		vec.y = 1
	elif Input.is_action_pressed("a"):
		vec.x = -1
	elif Input.is_action_pressed("d"):
		vec.x = 1
	move_and_collide(vec)
	vec.x = 0
	vec.y = 0
	
func _input(event):
	if event is InputEventMouseButton:
		if event.button_index == BUTTON_LEFT and event.is_pressed():
			var bullet = Bullet.instance()
			bullet.position = self.position
			get_parent().add_child(bullet)
			$gun.play()
